{% extends 'template.html' %}

{% block username %}
    {{ head.username }}
{% endblock %}

{% block content %}
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">{{ head.value }}</h1>
                <h1 class="page-header" id="wse_id" style="display: none;">{{ head.wse }}</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="container">
                                    <form role="form" class="form-horizontal">
                                        <div class="form-group">
                                            <label class="col-sm-12">申请人</label>
                                            <div class="col-sm-6">
                                                <input type="text" readonly class="form-control" id="applicant"
                                                       value={{ data.applicant.username }}>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-12" for="TextArea">标题</label>
                                            <div class="col-sm-6">
                                                <input type="text" readonly class="form-control" id="title"
                                                       value={{ data.title }}>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-12" for="TextArea">原因</label>
                                            <div class="col-sm-6">
                                                <textarea class="form-control" id="reason" readonly
                                                          rows="5">{{ data.reason }}</textarea>
                                            </div>
                                        </div>
                                        <div class="form-group" style="display: none">
                                            <label class="col-sm-12" for="TextArea">注意事项(可选)</label>
                                            <div class="col-sm-6">
                                                <textarea class="form-control" id="attention" readonly
                                                          rows="5">{{ data.attention }}</textarea>
                                            </div>
                                        </div>
                                        <br>
                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label">项目地区版本号</label>
                                            <div class="col-sm-3">
                                                <input type="text" readonly class="form-control" id="project"
                                                       value={{ data.project }}>
                                            </div>
                                            <div class="col-sm-3">
                                                <input type="text" readonly class="form-control" id="area_name"
                                                       value={{ data.area_name }}>
                                            </div>
                                            <div class="col-sm-3">
                                                <input type="text" readonly class="form-control" id="server_version"
                                                       value={{ data.server_version }}>
                                            </div>
                                        </div>
                                        <br>

                                        <div class="form-group row">
                                            <label class="col-sm-2 col-form-label">是否同步热更新服</label>
                                            <div class="col-sm-2">
                                                {% if data.on_new_server %}
                                                    <input type="text" readonly class="form-control" id="on_new_server"
                                                           value="是">
                                                {% else %}
                                                    <input type="text" readonly class="form-control" id="on_new_server"
                                                           value="否">
                                                {% endif %}
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-12" for="TextArea">后端热更新方式</label>
                                            <div class="col-sm-6">
                                                <input type="text" readonly class="form-control" id="hot_server_type"
                                                       value={{ data.hot_server_type }}>
                                            </div>
                                        </div>

                                        {% if data.show_file_list %}
                                            <div class="form-group show_update_file">
                                                <label class="col-sm-12" for="TextArea">要热更的文件和MD5</label>
                                                <div class="col-sm-6">
                                                    <textarea class="form-control" id="update_files" rows="6"
                                                              readonly="readonly">{{ data.update_file_list }}</textarea>
                                                </div>
                                            </div>
                                        {% endif %}

                                        {% if data.show_erlang_list %}
                                            <div class="form-group show_erlang_cmd">
                                                <label class="col-sm-12" for="TextArea">要执行的erl命令</label>
                                                <div class="col-sm-6">
                                                    <textarea class="form-control" id="erlang_cmd_list" rows="6"
                                                              readonly="readonly">{{ data.erlang_cmd_list }}</textarea>
                                                </div>
                                            </div>
                                        {% endif %}

                                        <!--<div class="form-group" id="show_overview_server_list">
                              <label class="col-sm-12" for="TextArea">更新的区服(游戏服类型+平台+游戏服名)</label>
                                <div class="col-sm-6">
                                    <textarea class="form-control" id="overview_server_list" rows="10" readonly="readonly">{{data.update_server_list}}</textarea>
                                </div>
                            </div>-->

                                        <div class="form-group" id="show_overview_server_list">
                                            <label class="col-sm-12">更新的区服</label>
                                            <div class="col-sm-6">
                                                <select id="server_list" multiple="multiple">
                                                    {% for gtype, gtype_fp_server_list in update_server_list.items %}
                                                        {% for pf, server_list in gtype_fp_server_list.items %}
                                                            {% for server in server_list %}
                                                                <option value={{ server.srv_id }} data-section={{ gtype }}/{{ pf }} data-srv={{ server.srv_id }} >{{ server.srv_name }};{{ server.srv_id }};{{ server.ip }}</option>
                                                            {% endfor %}
                                                        {% endfor %}
                                                    {% endfor %}
                                                </select>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-12" for="TextArea">
                                                和前端一起绑定热更新代号及先后顺序
                                            </label>
                                            <div class="col-sm-3">
                                                <input class="form-control" id="pair_code"
                                                       value={{ data.pair_code }} readonly="readonly"></input>
                                            </div>
                                            <div class="col-sm-3">
                                                <input class="form-control" id="order"
                                                       value={{ data.order }} readonly="readonly"></input>
                                            </div>
                                        </div>

                                        <div class="form-group" id="ystep1">
                                            <label class="col-sm-12">审核流程步骤</label>
                                            <div class="col-sm-6">
                                                <div class="ystep1"></div>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-1">审批意见</label>
                                            <div class="col-sm-6">
                                                {% if data.has_approved %}
                                                    <p>{{ data.state_value }}</p>
                                                {% else %}
                                                    {% for t in transitions %}
                                                        <label class="radio-inline {% if t.condition == '同意' %}text-success{% else %}text-danger{% endif %}">
                                                            <input type="radio" name='transitions'
                                                                   id={{ t.id }} condition={{ t.condition }} {% if t.condition == '同意' %}checked{% endif %}>{{ t.condition }}
                                                        </label>
                                                    {% endfor %}
                                                {% endif %}
                                            </div>
                                        </div>

                                        {% if not data.has_approved %}
                                            <div class="form-group">
                                                <label class="col-sm-12">审批意见(可选)</label>
                                                <div class="col-sm-6">
                                                    <textarea class="form-control" rows="3" id='opinion'
                                                              placeholder="你拒绝本次申请的理由是?"></textarea>
                                                </div>
                                            </div>
                                        {% endif %}

                                        {% if data.has_approved %}
                                        {% else %}
                                            <div class="form-group">
                                                <div class="col-sm-6">
                                                    <button type="button" class="btn btn-primary" id='bt-commit'>提交
                                                    </button>
                                                </div>
                                            </div>
                                        {% endif %}
                                    </form>
                                    <hr>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block bodyjs %}
    <script src="/static/js/server_hot_update_workflow_approve.js?v=809eb891ea97d3305e2b6f7c51b7d357ca650bda"></script>
    <script src="/static/js/flatpickr.js"></script>
    <script src="/static/js/zh.js"></script>
    <script src="/static/js/jquery.tree-multiselect.js"></script>
    <script src="/static/js/ystep.js"></script>
{% endblock %}
{% block css %}
    <link href="/static/css/ystep.css" rel="stylesheet" type="text/css">
    <link href="/static/css/flatpickr.css" rel="stylesheet" type="text/css">
    <link href="/static/css/jquery.tree-multiselect.css" rel="stylesheet" type="text/css">
{% endblock %}
